//
//  WedDeatilTableViewCell.m
//  MMLOOK
//
//  Created by dllo on 15/9/28.
//  Copyright © 2015年 武俊娥. All rights reserved.
//

#import "WedDeatilTableViewCell.h"

#import "WedModel.h"

#import "UIImageView+WebCache.h"

#define Labelwidth  [UIScreen mainScreen].bounds.size.width - 40

@interface WedDeatilTableViewCell ()


@property(nonatomic, retain)UIImageView *image;
@property(nonatomic, retain)UILabel *nameLable;
@property(nonatomic, retain)UILabel *commentLable;


@end

@implementation WedDeatilTableViewCell


-(void)dealloc
{
    [_image release];
    [_nameLable release];
    [_commentLable release];
    [super dealloc];
    
 
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
     
        self.image = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 40, 40)];
        self.image.layer.masksToBounds = YES;
        self.image.layer.cornerRadius = 20;
        
        [self.contentView addSubview:self.image];
        [_image release];
        
        self.nameLable = [[UILabel alloc]initWithFrame:CGRectMake(50, 15, 200, 20)];
        self.nameLable.textColor = [UIColor orangeColor];
        [self.contentView addSubview:self.nameLable];
        [_nameLable release];
        
        
        self.commentLable = [[UILabel alloc]init];
        self.commentLable.numberOfLines = 0;
        
        [self.contentView addSubview:self.commentLable ];
        [_commentLable release];

        
        
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    
    CGRect rect =  [self.commentLable.text boundingRectWithSize:CGSizeMake(Labelwidth, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    self.commentLable.frame = CGRectMake(20, 50, Labelwidth, rect.size.height);

}


-(void)sendValue:(WedModel *)model model1:(WedModel *)model1
{

    [self.image sd_setImageWithURL:[NSURL URLWithString:model1.avatar] placeholderImage:[UIImage imageNamed:@""]];
    
    self.nameLable.text = model1.nick;
    
    self.commentLable.text = model.content;
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
